<template>
    <div>
        <h1>权益修改</h1>
        <a href="/QY">返回</a>
        <table class="table">
            <tbody>
                <tr>
                    <td>权益名称</td>
                    <td>
                        <input type="text" v-model="data.Qyname">
                    </td>
                </tr>

                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" v-model="data.State" name="state" :value="true">启用
                        <input type="radio" v-model="data.State" name="state" :value="false">禁用
                    </td>
                </tr>

                <tr>
                    <td>权益描述</td>
                    <td>
                        <input type="text" v-model="data.Qysm">
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="修改" @click="Upts">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';


var touer=useRouter();
var toue=useRoute();

//权益的model
const data=ref({
    "Qid": 0,
  "Qyname": "",
  "State": true,
  "Qysm": ""
})

onMounted(() => {
    Ft();
})


//反填
const Ft=()=>{
    axios.get("https://localhost:7185/api/QY/GetQy",{params:{id:toue.query.id}}).then(res=>{
        data.value=res.data;
    })
}




//修改
const Upts=()=>{
    axios.put("https://localhost:7185/api/QY/UptQy",data.value).then(res=>{
        if(res.data==-1){
            alert("权益名称重复");
            return;
        }
        else
        if(res.data>0){
            alert("修改成功");
            touer.push({path:"/QY"});
        }else{
            alert("修改失败");
            return;
        }
    })
}



</script>

<style scoped>

</style>